package com.honglv.utils;

import com.github.qcloudsms.SmsSingleSender;
import com.github.qcloudsms.SmsSingleSenderResult;
import com.honglv.pojo.entity.Sms;

import javax.xml.ws.http.HTTPException;
import java.io.IOException;

import static com.honglv.pojo.entity.Sms.min;

/**
 * @Auther: 生
 * @Date: 2024/04/06/18:31
 * @Description:
 */
public class SendCodeUtil {
    public static void sms(Sms sms){
        int appid = 123;
        String appKey = "123";
        int templateId = 123;
        String smsSign = "123";
        try {
            String[] params = {sms.getCode(), String.valueOf(min)};
            SmsSingleSender ssender = new SmsSingleSender(appid,appKey);
            SmsSingleSenderResult result = ssender.sendWithParam("86",sms.getPhone(),templateId,params,smsSign,"","");
            System.out.println(result);
        }catch (HTTPException e){
            e.printStackTrace();
        } catch (IOException e){
            e.printStackTrace();
        } catch (com.github.qcloudsms.httpclient.HTTPException e) {
            throw new RuntimeException(e);
        }
    }
}
